
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>objects</title>
    {% load static %}
    <link rel="stylesheet" type="text/css" href="/static/css/objects.css"/>
    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>

<img src="/static/img/back3.jpg" style="background-size:contain; width:2080px;">
<div id="main">
    <h1><img src="/static/img/doc.jpg" width="110" height="100"/></h1>
    <hr style="width: 80%; margin: 0 auto; border: 1px; height: 1px; background-image: linear-gradient(to right, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0));">
    <h1>当前容器{{ data2 }}</h1>
    <a href="/containers"><button class="butt">返回上级页面</button></a>

    {% if resp1 %}
    <table border="1" align="center" style=" width:980px;height:150px;">
        <tr style="width:200px">
            <th style="height: 50px;width:180px">名称</th>
            <th style="height: 50px;width:180px">日期</th>
            <th style="height: 50px;width:180px">type</th>
            <th style="height: 50px;width:100px">文件大小</th>
            <th align="center" style="height: 20px;width:200px;">操作</th>
        </tr>
        {% for key in resp1 %}
        <tr>
            <td style="height: 30px;">{{ key.name }}</td>
            <td style="height: 30px;">{{ key.last_modified }}</td>
            <td style="height: 30px;">{{ key.content_type }}</td>
            <td style="height: 30px;">{{ key.bytes }}</td>
            <td align="center" style="height: 10px;">
                <input class="butt1" type="button" value="查看" onclick='window.location.href="/main3/{{ data2 }}/{{ key.name }}/{{ key.content_type }}"'>
                <input class="butt1" type="button" value="删除" onclick='window.location.href="/main4/{{ data2 }}/{{ key.name }}"'>
                <input class="butt1" type="button" value="下载" onclick='window.location.href="/download/{{ data2 }}/{{ key.name }}"' />
                <input class="butt1" type="button" value="复制" onclick="promptForTargetContainer('{{ data2 }}', '{{ key.name }}')" />
            </td>
        </tr>
        {% endfor %}
    </table>
    {% endif %}
    <div class="d-flex justify-content-center mt-4">
    {% if resp1.has_previous or resp1.has_next %}
        <nav aria-label="Page navigation">
            <ul class="pagination">
                {% if resp1.has_previous %}
                    <li class="page-item">
                        <a class="page-link" href="?page=1" aria-label="首页">
                            <span aria-hidden="true">&laquo;&laquo;</span>
                        </a>
                    </li>
                    <li class="page-item">
                        <a class="page-link" href="?page={{ resp1.previous_page_number }}" aria-label="上一页">
                            <span aria-hidden="true">&laquo;</span>
                        </a>
                    </li>
                {% else %}
                    <li class="page-item disabled">
                        <span class="page-link" aria-hidden="true">&laquo;&laquo;</span>
                    </li>
                    <li class="page-item disabled">
                        <span class="page-link" aria-hidden="true">&laquo;</span>
                    </li>
                {% endif %}

                {% for num in resp1.paginator.page_range %}
                    {% if resp1.number == num %}
                        <li class="page-item active" aria-current="page">
                            <span class="page-link">{{ num }}</span>
                        </li>
                    {% elif num > resp1.number|add:'-3' and num < resp1.number|add:'3' %}
                        <li class="page-item">
                            <a class="page-link" href="?page={{ num }}">{{ num }}</a>
                        </li>
                    {% endif %}
                {% endfor %}

                {% if resp1.has_next %}
                    <li class="page-item">
                        <a class="page-link" href="?page={{ resp1.next_page_number }}" aria-label="下一页">
                            <span aria-hidden="true">&raquo;</span>
                        </a>
                    </li>
                    <li class="page-item">
                        <a class="page-link" href="?page={{ resp1.paginator.num_pages }}" aria-label="末页">
                            <span aria-hidden="true">&raquo;&raquo;</span>
                        </a>
                    </li>
                {% else %}
                    <li class="page-item disabled">
                        <span class="page-link" aria-hidden="true">&raquo;</span>
                    </li>
                    <li class="page-item disabled">
                        <span class="page-link" aria-hidden="true">&raquo;&raquo;</span>
                    </li>
                {% endif %}
            </ul>
        </nav>

</div>
    {% else %}
    没有对象
    {% endif %}
    <form method="post" action="/upload/{{ data2 }}" enctype="multipart/form-data">
        {% csrf_token %}
        <input type="file" style="width:170px" name="myfile" />
        <input type="submit" value="上传" />
    </form>
</div>
<script>
    function promptForTargetContainer(sourceContainer, sourceObject) {
        var targetContainer = prompt("请输入目标容器名称:");
        if (targetContainer) {
            window.location.href = "/copy/" + encodeURIComponent(sourceContainer) + "/" + encodeURIComponent(sourceObject) + "/" + encodeURIComponent(targetContainer);
        }
    }
</script>

</body>
</html>
